home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip: Special XP & Vista
/
Chip Spesial XP & Vista.iso
/
3_Gadgets
/
UEFA_Informer_Gadget
/
UEFAinfo.gadget
/
scripts
/
menu.js
< prev
next >
Wrap
Text (UTF-16)
|
2008-03-28
|
17KB
|
277 lines
var prevPoint;
var checkedValue;
// checkedValue = [countryId;countryName;logo]
var countrySelId;
var numSelOption;
var paramFlyout;
function init_Menu()
{
if (System.Gadget.Settings.read("checkedValue"))
{
checkedValue = System.Gadget.Settings.read("checkedValue").split(",");
if (System.Gadget.Settings.read("countrySelId"))
{
countrySelId = System.Gadget.Settings.read("countrySelId");
numSelOption = System.Gadget.Settings.read("numSelOption");
}
else
{
countrySelId = checkedValue[0].split(";")[0];//first point mainmenu
numSelOption = 0;// first point submenu
}
}
else
{
// Default settings menu
set_DefaultMenu();
countrySelId = checkedValue[0].split(";")[0];//first point mainmenu
numSelOption = 0;// first point submenu
System.Gadget.Settings.write("checkedValue", checkedValue);
}
get_League();
}
function set_DefaultMenu()
{
checkedValue = [];
checkedValue[0] = "-1;Champions League;UCL.gif";
checkedValue[1] = "-2;UEFA Cup;uefacup.gif";
checkedValue[2] = "-3;Euro2008;euro2008.gif";
checkedValue[3] = "2;England;England.gif";
checkedValue[4] = "8;France;France.gif";
checkedValue[5] = "6;Germany;Germany.gif";
checkedValue[6] = "4;Italy;Italy.gif";
checkedValue[7] = "3;Spain;Spain.gif";
checkedValue[8] = "18;Ukraine;Ukraine.gif";
}
function get_League()
{
var content = document.getElementById("content");
content.innerHTML = "<p class='centered'><img src='images/loaderMain.gif'></p>";
show_Back();
//UEFA competitions
if (countrySelId < 0)
{
var url = "http://soccerdb.890m.com/xml/uefalist12.xml?a=1" + refreshRandom;
}
//National leagues
if (countrySelId > 0)
{
var url = "http://mbovin.com/soccerdb/export/grouplist.php?countryId=" + countrySelId + refreshRandom;
}
if (countrySelId == 0) return;
var httpreq = getHTTPObject();
httpreq.open("GET", url, true);
httpreq.onreadystatechange = function ()
{
if (httpreq.readyState == 4)
{
if (httpreq.status == 200)
{
var xml = httpreq.responseXML;
create_Menu(xml);
} else
{
content.innerHTML = "<p class='centered'>Error: Status " + httpreq.status + " (" + httpreq.statusText + ")</p>";
}
}
}
httpreq.send ();
}
function create_Menu(xml)
{
var lbFeeds = document.getElementById("lbFeeds");
lbFeeds.innerHTML = "";//Cleaning menu
//Create main section of menu
create_Option(0, "--------- Select --------", lbFeeds);
for (var i = 0; i < checkedValue.length; i++)
{
var countryValue = checkedValue[i];
var countryId = countryValue.split(";")[0];
var countryName = countryValue.split(";")[1];
var valueStr = "country;" + countryValue;
if (countrySelId == countryId)
{
var countrySelValue = countryValue;
var countrySelName = countryName;
} else
{
create_Option(valueStr, countryName, lbFeeds);
}
}
create_Option(0, "----------------------------", lbFeeds);
//Create subMenu section
if (countrySelId < 0)//UEFA leagues
{
var leagueNode = xml.documentElement.getElementsByTagName("league");
for (var i = 0; i < leagueNode.length; i++)
{
var countryId = getAttributeValue(leagueNode[i], "countryid");
if (countrySelId == countryId)
{
var stageNode = leagueNode[i].childNodes;
//Add headline
create_Option(0, countrySelName, lbFeeds, "#224871");
}
}
}
if (countrySelId > 0)//National leagues
{
var stageNode = xml.documentElement.getElementsByTagName("group");
//Add headline
var optgroup = document.createElement("optgroup");
optgroup.label = countrySelName;
lbFeeds.appendChild(optgroup);
}
var optionSubMenu = 0;
for (var i = 0; i < stageNode.length; i++)
{
//Stage level
var leagueId = getAttributeValue(stageNode[i], "leagueid");
var stageId = getAttributeValue(stageNode[i], "stageid");
var stageName = getChildNodeValue(stageNode[i], "name");
var stageValue = countrySelValue + ";" + leagueId + ";" + stageId + ";" + stageName;
var multigroup = getAttributeValue(stageNode[i], "multigroup");
switch (multigroup)
{
case "-1": //play-off format
if (countrySelId > 0) break;
var valueStr = "play-off;" + stageValue;
create_Option(valueStr, stageName, lbFeeds);
optionSubMenu += 1;
break;
case "0"://group format
//Group level
var valueStr = "group;" + stageValue;
create_Option(valueStr, stageName, optgroup);
optionSubMenu += 1;
break;
case "1": //multigroup format
if (countrySelId > 0) break;
//Add headline
var optgroup = document.createElement("optgroup");
optgroup.label = stageName;
lbFeeds.appendChild(optgroup);
//Group level
var groupNode = stageNode[i].childNodes;
for (var j = 0; j < groupNode.length; j++)
{
if (groupNode[j].nodeName == "group")
{
var groupId = getAttributeValue(groupNode[j], "id");
var groupName = getChildNodeValue(groupNode[j], "name");
var groupValue = stageValue + ";" + groupId + ";" + groupName;
var valueStr = "multigroup;" + groupValue;
create_Option(valueStr, groupName, optgroup);
optionSubMenu += 1;
}
}
break;
}
}
// Set selected option
if (numSelOption == 0)
{
numSelOption = lbFeeds.options.length - optionSubMenu;// first point submenu
}
lbFeeds.selectedIndex = numSelOption;
valueStr = lbFeeds.options[numSelOption].value;
change_Menu(valueStr);
}
function change_Menu(valueStr)
{
var lbFeeds = document.getElementById("lbFeeds");
var leagueName = document.getElementById("leagueName");
var content = document.getElementById("content");
if (valueStr == 0)//Nothing selected
{
lbFeeds.selectedIndex = prevPoint;
return;
}
var valueArr = valueStr.split(";");
// var valueStr = [country || play-off || group || multigroup;
// countryId;countryName;logo;
// leagueId;
// stageId;stageName;
// groupId;groupName]
switch (valueArr[0])
{
case "country"://New league selected
countrySelId = valueArr[1];
numSelOption = 0;
System.Gadget.Settings.write("countrySelId", countrySelId);
get_League();
return;
case "play-off"://Play-off match selected
var countryName = valueArr[2];
var logo = valueArr[3];
var leagueId = valueArr[4];
var stageId = valueArr[5];
var stageName = valueArr[6];
var paramStage = "stageId=" + stageId;
prevPoint = lbFeeds.selectedIndex;
System.Gadget.Settings.write("numSelOption", prevPoint);
content.innerHTML = "<br>Click link below to view <b>" + stageName + "</b> match results";
show_Back();
document.getElementById("flyOn").style.display = "";
resize_Win();
break;
case "group"://Group selected
var countryName = valueArr[2];
var logo = valueArr[3];
var leagueId = valueArr[4];
var stageId = valueArr[5];
var stageName = valueArr[6];
var paramStage = "stageId=" + stageId;
leagueName.innerHTML = countryName + "<br>" + stageName;//Table header
prevPoint = lbFeeds.selectedIndex;
System.Gadget.Settings.write("numSelOption", prevPoint);
get_TableXML(paramStage);
break;
case "multigroup"://Multigroup selected
var countryName = valueArr[2];
var logo = valueArr[3];
var leagueId = valueArr[4];
var stageId = valueArr[5];
var stageName = valueArr[6];
var groupId = valueArr[7];
var groupName = valueArr[8];
var paramStage = "stageId=" + stageId + "&" + "groupId=" + groupId;
leagueName.innerHTML = countryName + "<br>" + stageName + "<br>" + groupName;//Table header
prevPoint = lbFeeds.selectedIndex;
System.Gadget.Settings.write("numSelOption", prevPoint);
get_TableXML(paramStage);
// Replacement for flyout parametrs
countryName = stageName;
stageName = groupName;
break;
}
// Parameters for opening flyout window
paramFlyout = paramStage + ";";
paramFlyout += logo + ";";
paramFlyout += countryName + ";";
paramFlyout += stageName + ";";
paramFlyout += leagueId;
}
function create_Option(value, text, parentNode, colorFont)
{
var option = document.createElement("option");
option.value = value;
option.innerText = text;
if (colorFont != "") option.style.color = colorFont;
parentNode.appendChild(option);
}